package com.example.graduationdesignbackend.config;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.example.graduationdesignbackend.entity.Admin;
import com.example.graduationdesignbackend.service.IAdminService;
import com.example.graduationdesignbackend.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class Role implements StpInterface {

    @Autowired
    private IAdminService adminService;
    @Override
    public List<String> getRoleList(Object loginId, String loginType){
        String id = StpUtil.getLoginIdAsString();
        Admin admin = adminService.getInfo(id);
        List<String> roleList = new ArrayList<String>();
        if (BeanUtil.isEmpty(admin)){
            roleList.add("admin");
        }else{
            roleList.add("super-admin");
        }
        return roleList;
    }
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return null;
    }
}
